package lyx.tank.view
{
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.text.TextField;
	import flash.text.TextFieldAutoSize;
	
	import lyx.game.GameFramework;
	import lyx.game.element.GameElement;
	import lyx.game.locator.ElementLocator;
	import lyx.game.view.WorldView;
	import lyx.tank.element.AITank;
	import lyx.tank.engine.TankGameEngine;
	
	public class GameWorldView extends WorldView
	{
		private var _game_info_panel:Sprite = new Sprite();
		
		public function GameWorldView()
		{
			super();
			initInfoPanel();
		}
		
		override protected function initGameView(x:Number=0, y:Number=0, width:Number=640, height:Number=480):void
		{
			super.initGameView(0,0,480,480);
		}
		
		private function initInfoPanel():void
		{
			_game_info_panel.x = 480;
			_game_info_panel.graphics.beginFill(0x928f31);
			_game_info_panel.graphics.drawRect(0,0,160,480);
			_game_info_panel.graphics.endFill();
			addChild(_game_info_panel);
			
			var text_field:TextField = new TextField();
			text_field.text = "Tank War";
			text_field.background = true;
			text_field.backgroundColor = 0x666666;
			text_field.x = 20;
			text_field.y = 20;
			text_field.autoSize = TextFieldAutoSize.CENTER;
			_game_info_panel.addChild(text_field);
		}
		
		public function updateInfoPanel():void
		{
			var position_x:int = 20;
			var position_y:int = 60;
			var tank_number:int = 0;
			_game_info_panel.graphics.beginFill(0x928f31);
			_game_info_panel.graphics.drawRect(0,0,160,480);
			_game_info_panel.graphics.beginFill(0x000000);
			var ai_number:int = TankGameEngine(GameFramework.getInstance().engine).ai_tank_number;
			for (var i:int=0;i<ai_number;i++)
			{
				_game_info_panel.graphics.drawRect(position_x+i%2*20,position_y+int(i/2)*20,10,10);
			}
			_game_info_panel.graphics.endFill();
		}
	}
}